package edu.gatech.volt2.drdoommgt.presenter;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import edu.gatech.volt2.drdoommgt.domain.Patient;
import edu.gatech.volt2.drdoommgt.domain.TreatmentRecord;
import edu.gatech.volt2.drdoommgt.gui.IInvoiceView;
import edu.gatech.volt2.drdoommgt.gui.InvoiceView;
import edu.gatech.volt2.drdoommgt.system.DataBaseAccessor;

public class InvoicePresenter implements ActionListener{
	
	private IInvoiceView myView;
	private Patient myPatient;
	private DataBaseAccessor dba;
	
	public InvoicePresenter(DataBaseAccessor db, Patient p) {
		myPatient = p;
		myView = (IInvoiceView) new InvoiceView();
		myView.addListener(this);
		myView.setPatientName(p.getName());
		myView.showSelf();
		if ( ! p.getTreatmentRecords().isEmpty() ){
			int size = p.getTreatmentRecords().size();
			TreatmentRecord tr = p.getTreatmentRecords().get(size-1);
			myView.setTreatmentRecord(tr);
		}
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if ( e.getSource() == myView.getCloseButton() ){
			myView.hideSelf();
		}
	}

}